package com.guigu.qingcheng.orderservice.components;

import com.guigu.qingcheng.orderservice.service.TbCategoryReportService;
import com.guigu.qingcheng.orderservice.service.TbOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 与订单相关任务的定时器
 */

@Component
public class OrderTask {

    @Autowired
    private TbOrderService tbOrderService;
    @Autowired
    private TbCategoryReportService tbCategoryReportService;

    @Scheduled(cron = "0 0/60 * * * ?")
    public void orderTimeOutLogic () {
       tbOrderService.orderTimeOutLogic();
    }

    @Scheduled(cron = "0 0/60 * * * ?")
    public void orderTimeOutSh () {
        tbOrderService.orderTimeOutSh();
    }

    /**
     * 每天凌晨1点时执行该定时任务
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void createCategoryReportData() {
        System.out.println("生成类目统计数据");
        tbCategoryReportService.createData();
    }
}
